package twt.practice.votingsystem.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import twt.practice.votingsystem.service.ManageService;
import twt.practice.votingsystem.utils.APIResponse;

@RestController
public class ManageController {

    @Autowired
    ManageService manageService;

    @PostMapping("/managerfirstadd")
    public APIResponse addVote(@RequestParam("title_context") String title_context){
        return manageService.addVote(title_context);
    }

    @PostMapping("/managersecondadd")
    public APIResponse addChoice(@RequestParam("title_id") Integer title_id,
                                 @RequestParam("choice_context") String choice_context){
        return manageService.addChoice(title_id, choice_context);
    }

    @DeleteMapping("/managerfirstdelete")
    public APIResponse deleteVote(@RequestParam("title_context") String title_context){
        return manageService.deleteVote(title_context);
    }

    @DeleteMapping ("/managerseconddelete")
    public APIResponse deleteChoice(@RequestParam("title_context") String title_context,
                                 @RequestParam("choice_context") String choice_context){
        return manageService.deleteChoice(title_context, choice_context);
    }

    @GetMapping("/managerview")
    public APIResponse getConsequence(){
        return manageService.getConsequence();
    }
}
